#!/bin/bash

# 安装 chaosblade-box 项目的各个模块到本地 Maven 仓库

echo "开始安装 chaosblade-box 各个模块到本地 Maven 仓库..."
cd /Users/liwen/IdeaProjects/git/chaosblade-box

# 先安装父模块
mvn org.apache.maven.plugins:maven-install-plugin:3.1.2:install-file \
  -Dfile=pom.xml \
  -DgroupId=io.chaosblade \
  -DartifactId=chaosblade-box \
  -Dversion=1.0.5 \
  -Dpackaging=pom \
  -DlocalRepositoryPath=/Users/liwen/repository
echo "Successfully installed chaosblade-box parent module"

# 安装每个子模块到指定的本地仓库
modules=("agent-sdk" "cache" "common" "dao" "service" "toolsmgr" "starter")

for module in "${modules[@]}"; do
  if [ -f "chaosblade-box-$module/target/chaosblade-box-$module-1.0.5.jar" ]; then
    mvn org.apache.maven.plugins:maven-install-plugin:3.1.2:install-file \
      -Dfile=chaosblade-box-$module/target/chaosblade-box-$module-1.0.5.jar \
      -DgroupId=io.chaosblade \
      -DartifactId=chaosblade-box-$module \
      -Dversion=1.0.5 \
      -Dpackaging=jar \
      -DlocalRepositoryPath=/Users/liwen/repository
    echo "Successfully installed chaosblade-box-$module"
  else
    echo "ERROR: JAR file for chaosblade-box-$module not found"
  fi
done

echo "所有模块已成功安装到本地 Maven 仓库！"